//
//  CalculateTableViewCell.m
//  DanaKreditLoan
//
//  Created by ZhengChengFeng on 2024/10/20.
//

#import "CalculateTableViewCell.h"

@implementation CalculateTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        self.icon = [[UIImageView alloc] init];
        [self.contentView addSubview:self.icon];
        [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(15);
            make.top.equalTo(self.contentView.mas_top).offset(10);
            make.right.equalTo(self.contentView.mas_right).offset(-15);
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-10);
        }];
        
        self.icon1 = [[UIImageView alloc] init];
        [self.icon addSubview:self.icon1];
        [self.icon1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.icon.mas_left).offset(20);
            make.top.equalTo(self.icon.mas_top).offset(20);
            make.width.equalTo(@20);
            make.height.equalTo(@20);
        }];
        
        self.lab1 = [UILabel createLabel:[UIFont fontWithName:kFutura size:15] color:kBlackColor];
        [self.icon addSubview:self.lab1];
        [self.lab1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.icon1.mas_right).offset(5);
            make.right.equalTo(self.icon.mas_right).offset(-100);
            make.height.equalTo(@20);
            make.centerY.equalTo(self.icon1.mas_centerY);
        }];
        
        self.lab2 = [UILabel createLabel:[UIFont fontWithName:kFutura size:14] color:kBlackColor];
        [self.icon addSubview:self.lab2];
        [self.lab2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.icon.mas_right).offset(-20);
            make.height.equalTo(@20);
            make.centerY.equalTo(self.icon1.mas_centerY);
        }];
        
        self.lab3 = [UILabel createLabel:[UIFont fontWithName:kFutura size:14] color:[UIColor colorWithHexString:@"#6C6C6C"]];
        [self.icon addSubview:self.lab3];
        [self.lab3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.icon1.mas_left);
            make.right.equalTo(self.icon.mas_right).offset(-100);
            make.top.equalTo(self.icon1.mas_bottom);
            make.bottom.equalTo(self.icon.mas_bottom);
        }];
        
        self.lab4 = [UILabel createLabel:[UIFont fontWithName:kFutura size:16] color:kButtonDefaultColor];
        [self.icon addSubview:self.lab4];
        [self.lab4 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.icon.mas_right).offset(-20);
            make.top.equalTo(self.icon1.mas_bottom);
            make.bottom.equalTo(self.icon.mas_bottom);
        }];
        
        
    }
    return self;
}


- (void)setMod:(CalculateModel *)mod{
    _mod = mod;
    
    self.icon.image = [UIImage imageNamed:@"icon_calculate2"];
    self.icon1.image = [UIImage imageNamed:@"icon_Logo2"];
    
    self.lab1.text = @"Dana Kredit";
    self.lab3.text = @"Loan Amount";
    
    self.lab2.text = esString(mod.deserve);
    self.lab4.text = [NSString stringWithFormat:@"%.2lf",[mod.owed floatValue]];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
